<?php

class LoginController extends Controller {

    public function filters() {
        return CMap::mergeArray(parent::filters(), array(
                    'accessControl',
                    'https + index', // perform access control for CRUD operations
                ));
    }

    public function actionIndex() {
        $model = new LoginForm('index');

        // if it is ajax validation request
        // collect user input data
        if (isset($_POST['LoginForm'])) {
            $model->attributes = $_POST['LoginForm'];
            // validate user input and redirect to the previous page if valid
            if ($model->validate() && $model->login()) {
                $this->redirect('/LabSchool/index.php?r=PENGUASALABSCHOOL/default/loginSucces');
            } else {
                $this->redirect(Yii::app()->user->returnUrl);
            }
        } else {
            $this->renderPartial("/login/index", array('model' => $model));
        }
    }

    // Uncomment the following methods and override them if needed
    /*
      public function filters()
      {
      // return the filter configuration for this controller, e.g.:
      return array(
      'inlineFilterName',
      array(
      'class'=>'path.to.FilterClass',
      'propertyName'=>'propertyValue',
      ),
      );
      }

      public function actions()
      {
      // return external action classes, e.g.:
      return array(
      'action1'=>'path.to.ActionClass',
      'action2'=>array(
      'class'=>'path.to.AnotherActionClass',
      'propertyName'=>'propertyValue',
      ),
      );
      }
     */
}